﻿using System;
using System.Web.Mvc;
using System.Xml.Serialization;

namespace Limestone
{
    [Serializable]
    [XmlRoot("Field", Namespace = "http://www.limestone.se", IsNullable = false)]
    public class Field : IField
    {


        [XmlAttribute]
        public string Name { get; set; }
        [XmlAttribute]
        public int Index { get; set; }
        [XmlAttribute]
        public FieldType Type { get; set; }


        public Field()
        {
        }

        public Field (FieldType type, string name)
        {
            Type = type;
            Name = name;
        }

        // I can't make this abstract since I need to be able to serialize this class
        public virtual string GetHtml()
        {
            throw new NotSupportedException("First cast this field to its specific type, then use the overriden GetHtml() instead");
        }

        [XmlIgnore]
        public virtual IFieldSetting Settings { get; set; }
    }
}
